Skip to content

deps: replace raw-body with native approach#90

Open
SuperchupuDev wants to merge 1 commit into
top-gg-community:masterfrom
SuperchupuDev:deps/remove-many-many-subdependencies
Open

deps: replace raw-body with native approach#90
SuperchupuDev wants to merge 1 commit into
top-gg-community:masterfrom
SuperchupuDev:deps/remove-many-many-subdependencies

Conversation

@SuperchupuDev
Copy link
Copy Markdown

@SuperchupuDev SuperchupuDev commented Jun 23, 2024

raw-body was used in a way that it only converted the request to a Buffer. This PR replaces usage of raw-body with a less complex, native approach, removing not just the 11 dependencies that came with raw-body, but also undici's only subdependency (that was gone after updating undici). As such this PR lowers the amount of transitive dependencies in this package from 13 down to one (1).

I've tested that this approach and the way raw-body was used both give the same output, making this a free ~40% decrease in total bundle size

Code I ran to test

https://runkit.com/embed/4hcq12gepy26

image

@jpbberry jpbberry self-requested a review June 23, 2024 23:58
@MorganVonBrylan
Copy link
Copy Markdown

raw-body does a lot more than just retrieve the body though, it also checks the body length and handles things like stream abortions.

@velddev
Copy link
Copy Markdown
Contributor

velddev commented May 29, 2026

Would love to turn the SDK into a zero-dependency library, although we'd need a few more tests to ensure this would work across most HTTP clients such as express, hono, etc.

@SuperchupuDev
Copy link
Copy Markdown
Author

SuperchupuDev commented May 29, 2026

turning this into a zero dep library shouldn't be hard after this pr, i believe undici can be removed considering node versions below 18 are not supported oh undici was already removed :^)

raw-body does a lot more than just retrieve the body though, it also checks the body length and handles things like stream abortions.

is there a default length limit raw-body uses? as far as i'm aware the limit option which configures this is not in use. regarding aborting the stream, i can add some extra logic for handling that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants